package com.snail.billing.session;

import com.snail.billing.DataCache;
import com.snail.billing.net.BillingEncode;
import com.snail.billing.net.BillingSecurity;
import com.snail.billing.net.BillingTreeArrayHttpSession;

public class ResetPasswordEmailSession extends BillingTreeArrayHttpSession {

	public ResetPasswordEmailSession(String account, String emailtoken, String newPassword) {
		DataCache cache = DataCache.getInstance();
		String host = cache.importParams.hostSecurity;
		BillingSecurity security = getSecurity();
		String address = String.format("http://%s/api/%s/%s/resetpwdbyemail", host, security.accessId, security.accessType);
		setAddress(address);
		addBillingPair("account", account);
		addBillingPair("emailtoken", emailtoken);
		addBillingPair("newPassword", BillingEncode.enCode(newPassword, "UTF-8"));
		buildParamPair();
	}

	@Override
	public BillingSecurity getSecurity() {
		if (DataCache.getInstance().isSandbox) {
			return BillingSecurity.securitySandbox2;
		}
		return BillingSecurity.security;
	}

}
